﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace T6task3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string insSelect = "select UserName from User1";
            SqlDataReader IS = DBHelper.Selectsql(insSelect);
            if (!IS.Read())
            {
                string INsert1 =string.Format( "insert into User1(UserName,UserPwd) valuse ('{0}','{1}')",textBox1.Text,textBox2.Text);
                MessageBox.Show("注册成功！");
            }
            else
            {
                MessageBox.Show("账号已存在！！！");
            }
        }

        private void textBox1_Enter(object sender, EventArgs e)
        {
            if (textBox1.Text=="请输入账号")
            {
                textBox1.Text = "";
            }
        }

        private void textBox2_Enter(object sender, EventArgs e)
        {
            if (textBox2.Text == "请输入密码")
            {
                textBox2.Text = "";
            }
            
        }

        private void textBox1_Leave(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("账号不能为空！！！");
                textBox1.Focus();
            }
        }
    }
}
